from django.db import models

# Create your models here.
from django.db import models

# Create your models here.
from django.db import models
import PIL

class Seller(models.Model):
    id = models.AutoField(primary_key=True)
    name = models.CharField(max_length=32)
    nickname=models.CharField(max_length=32)
    password = models.CharField(max_length=32)

    # 显式声明默认管理器,PyCharm 的静态代码分析无法识别 Django 模型中动态添加的 objects 管理器。
    objects = models.Manager()


class Type(models.Model):
    id = models.AutoField(primary_key=True)
    name = models.CharField(max_length=32)

class Goods(models.Model):
    goods_num = models.CharField(max_length=32)
    goods_name = models.CharField(max_length=32)
    goods_oprice = models.IntegerField()
    goods_cprice = models.IntegerField()
    goods_kucun = models.IntegerField()
    goods_description = models.CharField(max_length=32)
    goods_detail = models.TextField()
    goods_sales = models.IntegerField()
    goods_browses = models.IntegerField(default=0)
    types = models.ForeignKey(to='Type',on_delete=models.CASCADE)
    seller = models.ForeignKey(to='Seller',on_delete=models.CASCADE)

    def __str__(self):
        return "goods object: {}-{}-{}-{}-{}-{}".format(self.goods_name,self.goods_cprice,self.goods_oprice,self.goods_browses,self.goods_detail,self.goods_num)

class Image(models.Model):
    img_address = models.ImageField()
    img_label = models.CharField(max_length=32)
    goods = models.ForeignKey(to='Goods',on_delete=models.CASCADE)